<?php

class  News extends CI_Controller {
   function __construct()
   {
       parent::__construct();

       $this->load->helper('url_helper');
       error_reporting(0);
   }

   function index(){
       $input = $this->input->get();

//       $data['news']  = $this->news_model->get_news();
//       $data['title'] = 'News archive';

       $this->load->view('templates/header', $data);
       $this->load->view('news/index', $data);
       $this->load->view('templates/footer');
   }

    public function view($slug = NULL)
    {
        $data['news_item'] = $this->news_model->get_news($slug);

        if (empty($data['news_item']))
        {
            show_404();
        }

        $data['title'] = $data['news_item']['title'];

        $this->load->view('templates/header', $data);
        $this->load->view('news/view', $data);
        $this->load->view('templates/footer');
    }

    function app_news($slug = null){
        $data = $this->news_model->get_news($slug);

        $data =array('id'=>'78','name'=>'小明');
        echo json_encode($data);
    }

}